The present invention relates to a control device equipped with an electrically erasable programmable read only memory (EEPROM) or a flash memory capable of electronically writing and erasing a program and data for controlling an electronic device in commercial and industrial use.
Conventionally, program data stored in an EPROM (electrically programmable read only memory) have been widely used for controlling an operation of an electronic device. The EPROM is a non-volatile type memory, and can store data even after the power is turned off. Therefore, the EPROM is suitable for a memory device for storing a program or reference data for executing a program. In the EPROM, it is not possible to electrically erase the stored content and to write a new program or data. Accordingly, when the program or data is changed, it is necessary to replace with the EPROM having the new program or data.
For this reason, recently in the technical field of a control device for controlling an electronic device in commercial and industrial use, there has been widely used a single chip microcomputer (hereinafter referred to as single chip computer), in which a CPU and an EEPROM or a flash memory are arranged in an integrated circuit on one chip. In the single chip computer, it is not necessary to connect to an external RAM or ROM. Accordingly, it is possible to access to an internal memory at a high speed. The single chip computer also has superior resistance against a line noise from an external source and an irradiated noise.
The EEPROM and flash memory, i.e. an improved EEPROM, (hereinafter, the EEPROM and flash memory are referred simply as EEPROM) are non-volatile memories capable of storing data even without electrical power similar to the EPROM described above. Accordingly, the EEPROM can store data that requires backup in case of power outage such as a program and function setting data of the CPU for controlling a device. Also, as opposed to the EPROM, the EEPROM is cable of electrically writing or erasing data. Accordingly, it is easy to write a program data when the program or setting data needs to correct a program bug or to upgrade.
Therefore, in the control device, an external device with an external memory medium wherein a writing program is stored is connected to a control substrate provided with the single chip computer. Then, an operator manually operates a dipswitch to execute the writing program stored in the external memory medium to write a program and data.
When a program in the EEPROM on the single chip computer is written, it is necessary to provide a dedicated apparatus for writing, thereby making it difficult to handle.
In order to solve this problem, Japanese Patent Publication (Kokai) No. 11-234491 has disclosed a control device in which a socket is provided on a substrate for mounting an EPROM for storing a writing program, so that the writing program stored in the EPROM is executed manually through an external operation. In the conventional control device, it is necessary to select a mode switch through the manual operation to execute the writing operation using the CPU arranged in the single chip computer, thereby making the operation troublesome.
When the single chip computer is not connected to a writing unit or the EPROM, an error may occur in executing the writing process through the manual operation, thereby making it troublesome to handle the writing unit or EPROM. In the EEPROM, when a new program and setting data are written, it is necessary to confirm whether the new program and setting data are written correctly through the writing process.
Japanese Patent Publication (Kokai) No. 08-30517 has disclosed a method for verifying whether a new program, data and setting data for writing are correctly written to the EEPROM. According to the method, a data region for storing a program and data, and a check region corresponding to the data region for storing check data to check the program and data are formed in a memory area of the EEPROM. In the control program for controlling the writing process to the EEPROM, a step is provided for obtaining a sum of the new programs and data to be stored in the data region whenever the EEPROM data is changed. A result obtained in the step is compared to the check data stored in the check region, so that it is verified that the new program and data stored in the data region are written correctly.
As disclosed in Japanese Patent Publication (Kokai) No. 10-333992, the EEPROM is provided therein with a data region for storing a program and data, a check region for storing check data for checking the program and data, and an adjusting data region for storing adjusting data preset such that the check data become specific values relative to a device. The specific values are compared to data obtained by adding the adjusting data to a sum of a first byte of the new program or data stored in the data region, so that it is verified whether the new program and data are suitable for the device.
In the verification method described above, when the writing is interrupted, there is a problem that it is determined that the writing is conducted correctly despite the interruption depending on the new programs and data.
In the verification method disclosed in Japanese Patent Publication (Kokai) No. 08-30517, when the writing suddenly stops during the writing process for the new program or data, the check data in the EEPROM is cleared, or FF is written in an 8-bit register. Accordingly, when the sum of the newly written program and data is FF, it is difficult to verify whether the writing is conducted correctly.
In the verification method disclosed in Japanese Patent Publication (Kokai) No. 10-333992, when the sum of the data interrupted while writing and matches to sum of the data when written correctly, i.e. the adjusted value of FF, it is difficult to verify whether the writing is conducted correctly.
An erroneous program or data due to the failed writing is executed as the correct program and data. In this case, the device may not operate correctly, or may operate in an uncontrolled state to cause damage, thereby causing a problem.
In view of the problems described above, an object of the present invention is to provide a control device for writing a control program and data, in which it is automatically verified that the program and data in an EEPROM are in a state that the program and data can be rewritten.
Another object of the present invention is to provide a control device capable of determining whether the program and data are written correctly and whether the writing operation is completed correctly when the program and data to be stored in EEPROM are rewritten.
Further objects and advantages of the invention will be apparent from the following description of the invention.